/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.utl.ist.isr.livetrack.tracker;

import java.awt.Image;
import java.awt.image.BufferedImage;
import org.apache.log4j.Logger;

/**
 *
 * @author David Miguel Antunes <davidmiguel [ at ] antunes.net>
 */
public class Detection {

    private static final Logger logger = Logger.getLogger(Detection.class);
    private final int camId;
    private final int topLeftX, topLeftY, width, height;
    private final double[] upperBodyHistogram, lowerBodyHistogram;
    private final BufferedImage image;

    public Detection(int camId, int[] boundingBox, double[] upperBodyHistogram, double[] lowerBodyHistogram, int[][][] image) {
        this.camId = camId;
        topLeftX = boundingBox[0];
        topLeftY = boundingBox[1];
        width = boundingBox[2];
        height = boundingBox[3];
        this.upperBodyHistogram = upperBodyHistogram;
        this.lowerBodyHistogram = lowerBodyHistogram;

        if (image != null) {
            BufferedImage i = new BufferedImage(image.length, image[0].length, BufferedImage.TYPE_3BYTE_BGR);
            for (int j = 0; j < image.length; j++) {
                for (int k = 0; k < image[0].length; k++) {
                    int[] rgb = image[j][k];
                    i.setRGB(j, k, (rgb[0]<<16) | (rgb[1] << 8) | (rgb[2] << 0));
                }
            }
            this.image = i;
        } else {
            this.image = null;
        }
    }

    public int getHeight() {
        return height;
    }

    public int getTopLeftX() {
        return topLeftX;
    }

    public int getTopLeftY() {
        return topLeftY;
    }

    public int getWidth() {
        return width;
    }

    public int getCamId() {
        return camId;
    }

    public BufferedImage getImage() {
        return image;
    }

    public double[] getLowerBodyHistogram() {
        return lowerBodyHistogram;
    }

    public double[] getUpperBodyHistogram() {
        return upperBodyHistogram;
    }
}
